// 封装所有地址相关的API函数

import httpInstance from "@/utils/http"

// 获取地址
export const getAddressAPI = () => {
  return httpInstance({
    url: '/member/address',
  })
}

// 添加地址
/*
data: {
  "receiver": "老李",
  "contact": "13900002020",
  "provinceCode": "210000",
  "cityCode": "210200",
  "countyCode": "210202",
  "address": "xxx街xxx路",
  "postalCode": "111006",
  "addressTags": "家里",
  "isDefault": 1,
  "fullLocation": "辽宁省 大连市 中山区"
}
 */
export const addAddressAPI = (data) => {
  return httpInstance({
    url: '/member/address',
    method: 'POST',
    data,
  })
}

// 修改地址
/*
{
  "receiver": "慕容复",
  "contact": "13966666666",
  "provinceCode": "320000",
  "cityCode": "320500",
  "countyCode": "320508",
  "address": "慕容山庄1",
  "postalCode": "415366",
  "addressTags": "姑苏慕容",
  "isDefault": 0,
  "fullLocation": "江苏省苏州市姑苏区",
  "id": "1539126595464204290"
}
*/
export const updateAddressAPI = (data) => {
  return httpInstance({
    url: `/member/address/${data.id}`,
    method: 'PUT',
    data,
  })
}

// 删除地址
export const delAddressAPI = (id) => {
  return httpInstance({
    url: `/member/address/${id}`,
    method: 'DELETE',
  })
}
